home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_11 / phillip2 / mainover.c < prev    next >
C/C++ Source or Header  |  1993-06-07  |  6KB  |  196 lines

  1.  
  2.        /*********************************************
  3.        *
  4.        *   file d:\cips\mainover.c
  5.        *
  6.        *   Functions: This file contains
  7.        *      main
  8.        *
  9.        *   Purpose:
  10.        *      This file contains the main calling
  11.        *      routine that calls the overlay functions.
  12.        *
  13.        *   External Calls:
  14.        *      gin.c - get_image_name
  15.        *      numcvrt.c - get_integer
  16.        *                  int_convert
  17.        *      tiff.c - read_tiff_header
  18.        *      overlay.c - non_zero_overlay
  19.        *                  zero_overlay
  20.        *                  greater_overlay
  21.        *                  less_overlay
  22.        *                  average_overlay
  23.        *
  24.        *   Modifications:
  25.        *      6 March 1993 - created
  26.        *
  27.        ***********************************************/
  28.  
  29. #include "cips.h"
  30.  
  31.  
  32.  
  33. short the_image[ROWS][COLS];
  34. short out_image[ROWS][COLS];
  35.  
  36. main(argc, argv)
  37.    int argc;
  38.    char *argv[];
  39. {
  40.  
  41.    char     name[80], name2[80], name3[80], type[80];
  42.    int      count, i, j,
  43.             il1, ie1, ll1, le1,
  44.             il2, ie2, ll2, le2,
  45.             il3, ie3, ll3, le3,
  46.             length, lw,
  47.             value, width;
  48.    struct   tiff_header_struct image_header;
  49.  
  50.    my_clear_text_screen();
  51.  
  52.        /*********************************************
  53.        *
  54.        *   Interpret the command line parameters.
  55.        *
  56.        **********************************************/
  57.  
  58.    if(argc < 5){
  59.     printf(
  60.     "\n\nNot enough parameters:"
  61.      "\n"
  62.      "\n usage: mainover in-file1 in-file2 out-file "
  63.      "type [il ie]"
  64.      "\n"
  65.      "\n recall type: nonzero zero greater less"
  66.      " average"
  67.      "\n"
  68.      "\n If in-file1 is only one ROWSxCOLS in size,"
  69.      "\n then specify il ie for in-file2"
  70.      "\n");
  71.     exit(0);
  72.    }
  73.  
  74.    strcpy(name,  argv[1]);
  75.    strcpy(name2, argv[2]);
  76.    strcpy(name3, argv[3]);
  77.    strcpy(type,  argv[4]);
  78.  
  79.    il1 = 1;
  80.    ie1 = 1;
  81.    ll1 = ROWS+1;
  82.    le1 = COLS+1;
  83.  
  84.    il2 = 1;
  85.    ie2 = 1;
  86.    ll2 = ROWS+1;
  87.    le2 = COLS+1;
  88.  
  89.    il3 = 1;
  90.    ie3 = 1;
  91.    ll3 = ROWS+1;
  92.    le3 = COLS+1;
  93.  
  94.        /*********************************************
  95.        *
  96.        *   Read the input image header and setup
  97.        *   the looping counters.
  98.        *
  99.        **********************************************/
  100.  
  101.    read_tiff_header(name, &image_header);
  102.  
  103.    length = (ROWS-10 + image_header.image_length)/ROWS;
  104.    width  = (COLS-10 + image_header.image_width)/COLS;
  105.    count  = 1;
  106.    lw     = length*width;
  107.    printf("\nlength=%d  width=%d", length, width);
  108.  
  109.    if(length == 1   &&   width == 1){
  110.       il2 = atoi(argv[5]);
  111.       ie2 = atoi(argv[6]);
  112.       il3 = il2;
  113.       ie3 = ie2;
  114.       ll2 = il2+ROWS;
  115.       le2 = ie2+COLS;
  116.       ll3 = il3+ROWS;
  117.       le3 = ie3+COLS;
  118.    }  /* ends if length == width == 1 */
  119.  
  120.        /*********************************************
  121.        *
  122.        *   Loop over the input images and
  123.        *   apply the desired overlay function.
  124.        *
  125.        **********************************************/
  126.  
  127.    for(i=0; i<length; i++){
  128.       for(j=0; j<width; j++){
  129.          printf("\nrunning %d of %d", count, lw);
  130.          count++;
  131.  
  132.             /* non-zero */
  133.          if(strncmp("non", type, 3) == 0){
  134.             non_zero_overlay(name, name2, name3,
  135.                               the_image, out_image,
  136.                               il1+i*ROWS, ie1+j*COLS,
  137.                               ll1+i*ROWS, le1+j*COLS,
  138.                               il2+i*ROWS, ie2+j*COLS,
  139.                               ll2+i*ROWS, le2+j*COLS,
  140.                               il3+i*ROWS, ie3+j*COLS,
  141.                               ll3+i*ROWS, le3+j*COLS);
  142.          }  /* ends non_zero operation */
  143.  
  144.             /* zero */
  145.          if(strcmp("zero", type) == 0){
  146.             zero_overlay(name, name2, name3,
  147.                          the_image, out_image,
  148.                          il1+i*ROWS, ie1+j*COLS,
  149.                          ll1+i*ROWS, le1+j*COLS,
  150.                          il2+i*ROWS, ie2+j*COLS,
  151.                          ll2+i*ROWS, le2+j*COLS,
  152.                          il3+i*ROWS, ie3+j*COLS,
  153.                          ll3+i*ROWS, le3+j*COLS);
  154.          }  /* ends zero operation */
  155.  
  156.             /* greater */
  157.          if(strncmp("gre", type, 3) == 0){
  158.             greater_overlay(name, name2, name3,
  159.                              the_image, out_image,
  160.                              il1+i*ROWS, ie1+j*COLS,
  161.                              ll1+i*ROWS, le1+j*COLS,
  162.                              il2+i*ROWS, ie2+j*COLS,
  163.                              ll2+i*ROWS, le2+j*COLS,
  164.                              il3+i*ROWS, ie3+j*COLS,
  165.                              ll3+i*ROWS, le3+j*COLS);
  166.          }  /* ends greater operation */
  167.  
  168.             /* less */
  169.          if(strncmp("les", type, 3) == 0){
  170.             less_overlay(name, name2, name3,
  171.                           the_image, out_image,
  172.                           il1+i*ROWS, ie1+j*COLS,
  173.                           ll1+i*ROWS, le1+j*COLS,
  174.                           il2+i*ROWS, ie2+j*COLS,
  175.                           ll2+i*ROWS, le2+j*COLS,
  176.                           il3+i*ROWS, ie3+j*COLS,
  177.                           ll3+i*ROWS, le3+j*COLS);
  178.          }  /* ends less operation */
  179.  
  180.             /* average */
  181.          if(strncmp("ave", type, 3) == 0){
  182.             average_overlay(name, name2, name3,
  183.                              the_image, out_image,
  184.                               il1+i*ROWS, ie1+j*COLS,
  185.                               ll1+i*ROWS, le1+j*COLS,
  186.                               il2+i*ROWS, ie2+j*COLS,
  187.                               ll2+i*ROWS, le2+j*COLS,
  188.                               il3+i*ROWS, ie3+j*COLS,
  189.                               ll3+i*ROWS, le3+j*COLS);
  190.          }  /* ends average operation */
  191.  
  192.  
  193.       }  /* ends loop over j */
  194.    }  /* ends loop over i */
  195. }  /* ends main  */
  196.